Skip to content

fix(agent_orchestration): Unbounded timeout for delegation tools — delegate_tools_agent, run_code (#4734)#4741

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
oxoxDev:fix/4734-delegation-tool-timeout
Jul 14, 2026
Merged

fix(agent_orchestration): Unbounded timeout for delegation tools — delegate_tools_agent, run_code (#4734)#4741
senamakel merged 1 commit into
tinyhumansai:mainfrom
oxoxDev:fix/4734-delegation-tool-timeout

Conversation

@oxoxDev

@oxoxDev oxoxDev commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Delegation tools (delegate_tools_agent, run_code, and any other archetype-delegate tool) now opt out of the global 120s per-tool wall-clock, so a sub-agent run that legitimately takes longer than two minutes is no longer hard-killed mid-flight.
  • Fixes two high-volume Sentry crashes with one change: TAURI-RUST-K29 (delegate_tools_agent, 1236 events / 71 users) and TAURI-RUST-8HB (run_code, 755 events / 51 users).

Problem

Both delegate_tools_agent and run_code are synthesized by the same type, ArchetypeDelegationTool. It never overrode timeout_policy(), so it inherited ToolTimeout::Inherit = the global per-tool cap (tool_timeout::DEFAULT_TIMEOUT_SECS = 120). Every tool call is wrapped in tokio::time::timeout(deadline, exec), so a delegation whose sub-agent runs past 120s was hard-killed at exactly 120.000s and truncated — surfacing as tool '<name>' timed out after 120 seconds. The delegated agents are internally bounded (their agent.toml max_iterations, the run cancellation token, and each inner tool's own timeout), so the 120s cap doesn't protect against runaway work — it just truncates legitimate long-running delegation.

The sibling spawn_parallel_agents tool had this exact bug fixed in #4686 (timeout_policy -> Unbounded); the long-running scripting tools (shell, node_exec, npm_exec) are already Unbounded-by-default. ArchetypeDelegationTool was simply missed.

Solution

Override timeout_policy() -> ToolTimeout::Unbounded on ArchetypeDelegationTool, mirroring #4686. The child agent governs its own lifetime, so the delegation primitive should not impose the single-tool wall-clock. Adds a unit test asserting the override (mirrors spawn_parallel_agents_tests).

Scope is deliberately narrow: SkillDelegationTool (→ integrations_agent, quick Composio actions) and the base DelegateTool route to short-lived agents and are intentionally left on the default — no speculative widening.

RCA-vs-suppress: Bucket = real-defect (a wrong timeout policy truncating internally-bounded work). This corrects the policy; it is not a suppression.

Submission Checklist

  • Tests added or updated (happy path + edge case) — unit test asserts timeout_policy() == Unbounded; existing ArchetypeDelegationTool tests cover the delegation happy/blank-prompt paths
  • Diff coverage ≥ 80% — verified locally via cargo-llvm-cov + diff-cover --compare-branch=upstream/main: 100% on changed lines (7/7)
  • Coverage matrix updated — N/A: behaviour-only reliability change (no feature row)
  • All affected feature IDs listed under ## RelatedN/A
  • No new external network dependencies introduced
  • Manual smoke checklist updated if release-cut surfaces touched — N/A: internal tool-timeout policy
  • Linked issue closed via Closes #NNN in ## Related

Impact

  • Platform: desktop (all) — agent delegation path.
  • Behavior: long delegated sub-agent runs complete instead of dying at 120s. No change to healthy short delegations. The child is still bounded by its own iteration cap + run cancellation token, so this cannot cause an unbounded runaway.
  • No schema, API, or migration change. One-line policy override + test.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

Commit & Branch

Validation Run

  • pnpm --filter openhuman-app format:check — N/A (no app/ changes)
  • pnpm typecheck — N/A (no TS changes)
  • Focused tests: delegation_opts_out_of_the_global_tool_timeoutpasses (test result: ok. 1 passed)
  • Rust fmt/check (if changed): cargo fmt --check clean, cargo check --lib clean, cargo clippy --lib clean on the changed file
  • Tauri fmt/check (if changed): N/A

Behavior Changes

  • Intended behavior change: archetype-delegation tools run without the 120s single-tool wall-clock.
  • User-visible effect: long agent-delegation tasks complete instead of failing with a 120s timeout.

Parity Contract

Duplicate / Superseded PR Handling

Summary by CodeRabbit

  • Bug Fixes
    • Delegated tool operations can now run without being cut off by the global tool timeout.
    • Delegation behavior remains consistent when processing longer-running requests.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55df7731-784d-4928-9a24-26180050ecfe

📥 Commits

Reviewing files that changed from the base of the PR and between c58fe10 and 3f84918.

📒 Files selected for processing (1)
  • src/openhuman/agent_orchestration/tools/archetype_delegation.rs

📝 Walkthrough

Walkthrough

ArchetypeDelegationTool now opts out of the inherited global tool timeout by returning ToolTimeout::Unbounded. Inline documentation explains delegation timeout behavior, and a unit test verifies the policy.

Changes

Delegation timeout handling

Layer / File(s) Summary
Unbounded timeout policy and validation
src/openhuman/agent_orchestration/tools/archetype_delegation.rs
ArchetypeDelegationTool imports ToolTimeout, returns ToolTimeout::Unbounded, documents the behavior, and tests the override.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: agent

Suggested reviewers: m3ga-mind

Poem

I’m a bunny with a timer set free,
No 120-second wall for me.
Delegations hop onward,
Tests stand watch beyond yonder—
Unbounded as can be! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the delegation-tool timeout fix and matches the main change.
Linked Issues check ✅ Passed The PR overrides ArchetypeDelegationTool to Unbounded and adds a test, matching #4734's requested fix.
Out of Scope Changes check ✅ Passed The changes stay focused on the delegation timeout policy and its test, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands.

@oxoxDev oxoxDev force-pushed the fix/4734-delegation-tool-timeout branch from c408115 to 5df7911 Compare July 9, 2026 21:04
@oxoxDev oxoxDev marked this pull request as ready for review July 9, 2026 21:26
@oxoxDev oxoxDev requested a review from a team July 9, 2026 21:26
…yhumansai#4734)

ArchetypeDelegationTool synthesizes delegate_tools_agent (tools_agent) and
run_code (code_executor). It defaulted to ToolTimeout::Inherit = the global
120s per-tool cap, so any delegated sub-agent run exceeding two minutes was
hard-killed and truncated (Sentry TAURI-RUST-K29: 1236 events / 71 users;
TAURI-RUST-8HB: 755 / 51). The child bounds its own lifetime via max_iterations,
the run cancellation token, and each inner tool's timeout, so override
timeout_policy -> Unbounded, matching spawn_parallel_agents (tinyhumansai#4686) and the
long-running scripting tools. Adds a unit test asserting the override.
@oxoxDev oxoxDev force-pushed the fix/4734-delegation-tool-timeout branch from 5df7911 to 3f84918 Compare July 13, 2026 05:55
@coderabbitai coderabbitai Bot added the agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. label Jul 13, 2026
@senamakel senamakel merged commit bddebcb into tinyhumansai:main Jul 14, 2026
20 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delegation tools (delegate_tools_agent, run_code) hard-killed at 120s: ArchetypeDelegationTool needs Unbounded timeout_policy

2 participants